﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTA;

namespace GTAHookAdv
{
    /// <summary>
    /// This class extends GTA.Ped class.
    /// </summary>
    public class g_Ped 
    {
        Ped _ped;

        /// <summary>
        /// The only constructor, it need a valid ped to extend its features.
        /// </summary>
        /// <param name="ped">an non null ped</param>
        /// <exception cref="ArgumentNullException">if <paramref name="ped"/>is null</exception>
        /// <remarks> if ped doesn't exists, most methods will do nothing to prevent an exception</remarks>
        public g_Ped(Ped ped)
        {
            if (ped == null)
                throw new ArgumentNullException("ped");
            _ped = ped;
        }

        /// <summary>
        /// Result is sure, the ped will stop doing anything, like a vegetable !
        /// </summary>
        /// <param name="ped">guess</param>
        public static void TasksClear(Ped ped)
        {
           g_Ped intped = new g_Ped(ped);
            intped.TasksClear();
        }

        /// <summary>
        /// Result is sure, the ped will stop doing anything, like a vegetable !
        /// </summary>
        
        public void TasksClear()
        {
            if (_ped.Exists())
            {
                _ped.Task.ClearAll();
                _ped.BlockPermanentEvents = true;
                _ped.BlockGestures = true;
                _ped.BlockWeaponSwitching = true;
            }
        }

        /// <summary>
        /// stop to block events and gestures
        /// </summary>
        public static void TasksResume(Ped ped)
        {
            g_Ped intped = new g_Ped(ped);
            intped.TasksResume();
        }

        /// <summary>
        /// stop to block events and gestures
        /// </summary>
        public void TasksResume()
        {
            if (_ped.Exists())
            {
                _ped.BlockPermanentEvents = false;
                _ped.BlockGestures = false;
                _ped.BlockWeaponSwitching = false;
            }
        }
    }
}
